home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 24
/
Amiga Format AFCD24 (Feb 1998, Issue 108).iso
/
-in_the_mag-
/
emulation
/
-otherstuff-
/
amiganpi
/
src_blitz
/
crc16.asc
< prev
next >
Wrap
Text File
|
1998-01-05
|
2KB
|
75 lines
;CRC handling
crcinit.l=0;
Dim crctab.l(256)
For i=0 To 255
Read crctab(i)
Next i
crcdata:
Data.l $0000, $c0c1, $c181, $0140, $c301, $03c0, $0280, $c241
Data.l $c601, $06c0, $0780, $c741, $0500, $c5c1, $c481, $0440
Data.l $cc01, $0cc0, $0d80, $cd41, $0f00, $cfc1, $ce81, $0e40
Data.l $0a00, $cac1, $cb81, $0b40, $c901, $09c0, $0880, $c841
Data.l $d801, $18c0, $1980, $d941, $1b00, $dbc1, $da81, $1a40
Data.l $1e00, $dec1, $df81, $1f40, $dd01, $1dc0, $1c80, $dc41
Data.l $1400, $d4c1, $d581, $1540, $d701, $17c0, $1680, $d641
Data.l $d201, $12c0, $1380, $d341, $1100, $d1c1, $d081, $1040
Data.l $f001, $30c0, $3180, $f141, $3300, $f3c1, $f281, $3240
Data.l $3600, $f6c1, $f781, $3740, $f501, $35c0, $3480, $f441
Data.l $3c00, $fcc1, $fd81, $3d40, $ff01, $3fc0, $3e80, $fe41
Data.l $fa01, $3ac0, $3b80, $fb41, $3900, $f9c1, $f881, $3840
Data.l $2800, $e8c1, $e981, $2940, $eb01, $2bc0, $2a80, $ea41
Data.l $ee01, $2ec0, $2f80, $ef41, $2d00, $edc1, $ec81, $2c40
Data.l $e401, $24c0, $2580, $e541, $2700, $e7c1, $e681, $2640
Data.l $2200, $e2c1, $e381, $2340, $e101, $21c0, $2080, $e041
Data.l $a001, $60c0, $6180, $a141, $6300, $a3c1, $a281, $6240
Data.l $6600, $a6c1, $a781, $6740, $a501, $65c0, $6480, $a441
Data.l $6c00, $acc1, $ad81, $6d40, $af01, $6fc0, $6e80, $ae41
Data.l $aa01, $6ac0, $6b80, $ab41, $6900, $a9c1, $a881, $6840
Data.l $7800, $b8c1, $b981, $7940, $bb01, $7bc0, $7a80, $ba41
Data.l $be01, $7ec0, $7f80, $bf41, $7d00, $bdc1, $bc81, $7c40
Data.l $b401, $74c0, $7580, $b541, $7700, $b7c1, $b681, $7640
Data.l $7200, $b2c1, $b381, $7340, $b101, $71c0, $7080, $b041
Data.l $5000, $90c1, $9181, $5140, $9301, $53c0, $5280, $9241
Data.l $9601, $56c0, $5780, $9741, $5500, $95c1, $9481, $5440
Data.l $9c01, $5cc0, $5d80, $9d41, $5f00, $9fc1, $9e81, $5e40
Data.l $5a00, $9ac1, $9b81, $5b40, $9901, $59c0, $5880, $9841
Data.l $8801, $48c0, $4980, $8941, $4b00, $8bc1, $8a81, $4a40
Data.l $4e00, $8ec1, $8f81, $4f40, $8d01, $4dc0, $4c80, $8c41
Data.l $4400, $84c1, $8581, $4540, $8701, $47c0, $4680, $8641
Data.l $8201, $42c0, $4380, $8341, $4100, $81c1, $8081, $4040
#M1=$ff
#M2=$ff00
#TIMEOUT=-2
Function updcrc{icrc.l,icp.l,icnt.l}
SHARED crctab()
crc.l = icrc
cp.l = icp
cnt.l = icnt
While cnt>0
cnt-1
crc=Xor((crc ASR 8)M1,crctab(Xor(crcM1,Peek.b(cp)M1)))
cp+1
Wend
Function Return crc
End Function
Statement fcscalc{fcs.l,d$}
;fcs is a pointer to a variable
Poke.l fcs,updcrc{Peek.l(fcs),&d$,1}
End Statement